package org.op.service.wwcache;

import java.util.List;
import java.util.Properties;

import org.op.service.WwDocumentInfo;

public interface WikiwordCacheService {

	/**
	 * 
	 *  Returns a Map between wikiwords and their aliases
	 * 
	 * @return
	 */
	public Properties getAliasMap();
	

	/**
	 *   Gets the Document info for a give wikiword
	 * @param ww 
	 *   
	 * @return
	 * @throws Exception 
	 */
	public WwDocumentInfo getInfoForWikiword(String ww) throws Exception;
	
	/**
	 *  Populates or refreshes the alias map
	 * 
	 * @return
	 * @throws Exception
	 */
	public Properties loadAliases() throws Exception;
	
	/**
	 *  Persists the alias information
	 *  
	 * @throws Exception
	 */
	public void saveAliases() throws Exception;
	
	/**
	 *  Add an alias to the wikiword map (and persists)
	 * 
	 * @param wikiword
	 * @param path
	 * @throws Exception
	 */
	public void addAlias(String wikiword, String path) throws Exception;
	
	/**
	 *  Updates all of the aliases that point to this path to the new path
	 * 
	 * @param wikiword
	 * @param newPath
	 * @throws Exception
	 */
	public void updateAliasPath(String oldPath, String newPath) throws Exception;
	
	/**
	 *  Removes the property from the path and persist
	 * 
	 * @param wikiword
	 * @throws Exception
	 */
	public void removeAlias(String wikiword) throws Exception;

	/**
	 *  Updates the alias list and replaces all occurrences of the given filepath
	 *    with the new list of aliases
	 * 
	 * @param aliasList
	 * @param filepath
	 */
	public void setAliasesForFile(List<String> aliasList, String filepath) throws Exception;


	/**
	 *  Gets all aliases that match this document path
	 *  
	 * @param string
	 * @return
	 */
	public List<String> getAliasesForDocument(String string);
	
	
}
